package top.zuli.package02.homework15;

import org.junit.Test;

public class Demo3 {
    @Test
    public void demo(){
        StringBuffer sb = new StringBuffer("abcdabcdabcd");
        int count = 0;
        while (true){
            if (sb.indexOf("ab") != -1){
                count++;
                sb.delete(sb.indexOf("ab"),sb.indexOf("ab")+2);
            }else {
                break;
            }
        }
        System.out.println("ab出现的次数为："+count);
    }
}
